//
//  ShouVC.swift
//  AliBaiChuan
//
//  Created by 郑东喜 on 2017/2/9.
//  Copyright © 2017年 郑东喜. All rights reserved.
//  首页

import UIKit

class ShouVC: UIViewController {

    fileprivate lazy var label : UILabel = {
        let lab : UILabel = UILabel.init(frame: self.view.bounds)
        lab.text = "单机屏幕加载页面"
        lab.textAlignment = .center
        return lab
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
    
        view.addSubview(label)
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.openURL()
    }
}

extension ShouVC {
    ///打开指定url页面
    func openURL() -> Void {
        print("\((#file as NSString).lastPathComponent):(\(#line))",ViewController.shared.getTB())
        
        let page = AlibcTradePageFactory.page(_shouyeURL)
        let service = AlibcTradeSDK.sharedInstance().tradeService()
        
        let showParams : AlibcTradeShowParams = AlibcTradeShowParams()
        showParams.openType = .H5
        
        
        ///加入词句调用天猫
        service?.show(showParams.isNeedPush ? self.navigationController! : self,
                      page: page,
                      showParams:showParams,
                      
                      taoKeParams: nil,
                      trackParam: ["track_key":"track_value"], tradeProcessSuccessCallback: { (result) in
                        print("\((#file as NSString).lastPathComponent):(\(#line))",result as Any)
                        
        }, tradeProcessFailedCallback: { (error) in
            
        })
    }
}
